package cn.bugstack.domain.strategy.repository;

import cn.bugstack.domain.strategy.model.entity.StrategyAwardEntity;
import cn.bugstack.domain.strategy.model.entity.StrategyEntity;
import cn.bugstack.domain.strategy.model.entity.StrategyRuleEntity;
import cn.bugstack.domain.strategy.model.valobj.StrategyAwardRuleModelVO;

import java.util.List;
import java.util.Map;

/**
 * TODO
 *
 * @Description
 * @Author 1
 * @Date 2024/7/29 0:35
 **/
public interface IStrategyRepository {

    //1.查询指定策略中的奖品
    List<StrategyAwardEntity> queryStrategyAwardList(Long strategyId);


    //2.存储查询到的各奖品及其概率的Map表到redis中去，抽奖就从这个redis中去获取
    void storeStrategyAwardSearchRateTable(Long strategyId, int size, Map<Integer, Integer> shuffleStrategyAwardSearchRateMap);



    //3.获取策略奖品
    int getStrategyAwardAssemble(Long strategyId, int RandomValue);


    //4.根据策略ID获取策略抽奖的概率的范围
    int getRateRange(Long strategyId);

    //5.根据策略ID拿到策略实体
    StrategyEntity queryStrategyEntityByStrategyId(Long strategyId);

    //6.根据策略ID和策略规则名称拿到策略规则详情
    //普通的拿到策略ID的所有的规则
    StrategyRuleEntity queryStrategyRuleByStrategyIdAndRuleName(Long strategyId, String ruleWeight);

    //7.根据策略ID_策略权重拿到抽奖的概率范围
    int getRateRange(String cacheKey);

    //8.查询规则值配置(根据策略ID、奖品ID、规则名称拿到规则详情String)(/*因为每种奖品可能有不同的规则，不同的规则也可以对应多个奖品，属于是多对多的关系*/)，
    // 精确的拿到指定的奖品和指定的策略ID的所拥有的规则
    String queryStrategyRuleValue(Long strategyId, Integer awardId, String ruleModel);

    //9.查询策略规则
    StrategyAwardRuleModelVO queryStrategyAwardRuleModelVO(Long strategyId, Integer awardId);

    //10.查询策略规则值
    String queryStrategyRuleValue(Long strategyId, String ruleModel);

    //11.发送扣减库存的消息到延迟队列中
    void sendDeductStockMsg(Long strategyId, Integer awardId);

    //12.缓存中库存的扣减
    void DecrStockFromCache();
}
